import org.junit.Before;
import org.junit.Test;

import java.io.PrintStream;

import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

/**
 * Created with IntelliJ IDEA.
 * User: Thoughtworker
 * Date: 8/25/13
 * Time: 2:23 PM
 * To change this template use File | Settings | File Templates.
 */
public class ScoreAppTest {
    ScoreApp scoreWithMocks;
    ScoreApp score;
    private Game gameMock;
    private PrintStream printStreamMock;
    private Game game;

    @Before
    public void setup() {
        gameMock = mock(Game.class);
        scoreWithMocks = new ScoreApp(gameMock, printStreamMock);
        printStreamMock = mock(PrintStream.class);
        game = new Game(new Player(1), new Player(2));
        score = new ScoreApp(game, printStreamMock);
    }

    @Test
    public void shouldDisplayScoreUsingPrintStream() throws Exception {
        score.displayScore();
        verify(printStreamMock).println("0/0");
    }

    @Test
    public void shouldDisplayScore1515() throws Exception {
        game.scorePointPlayer(1);
        game.scorePointPlayer(2);
        score.displayScore();
        verify(printStreamMock).println("15/15");
    }

    @Test
    public void shouldDisplayScoreAsDeuceWhenScoreIsDeuceWhenScoreIsFortyToForty() throws Exception {
        game.scorePointPlayer(1);
        game.scorePointPlayer(1);
        game.scorePointPlayer(1);
        game.scorePointPlayer(2);
        game.scorePointPlayer(2);
        game.scorePointPlayer(2);
        score.displayScore();
        verify(printStreamMock).println("Deuce");
    }
}
